const { ccclass, property } = cc._decorator;

import AudioManager from "./AudioManager";
import SystemDataSys from "./SystemDataSys";
import frameworkManager from "./frameworkManager";
import SdkHelper from "./SdkHelper";
import MatchGameViewCtrl from "./MatchGameViewCtrl";
import UiManage from "./UiManage";
import MatchGameData from "./MatchGameData";
import UiManager from "./UiManage";

@ccclass
export default class EditorGameMain extends cc.Component {

    @property(cc.Node)
    checkNode = null;

    onLoad() {
        AudioManager.getInstance().init();
        MatchGameData.isEditor = false;

        const t = location.search;
        frameworkManager.log("search-----", t);

        // if (t) {
        //     const o = t.split("?")[1];
        //     if (o) {
        //         const i = o.split("=")[1];
        //         if (i) {
        const url = "https://static.dayclover.com/feie/level_config/" + 1 + ".json";
        cc.assetManager.loadRemote(url, cc.JsonAsset, (err, asset) => {
            if (err) {
                frameworkManager.error("加载关卡资源报错----", err);
            } else {
                UiManager.loaderViewDeepPath(this.node, "MatchGameView", "MatchGame/view", {
                    levelInfo: asset['json']
                }).then(() => {
                    this.node.getChildByName("MatchGameView").getComponent(MatchGameViewCtrl).initGameData(asset.json.data.profile.LEVEL_CODE);
                });
            }
        });
        //         } else {
        //             UiManager.loaderViewDeepPath(this.node, "MatchGameView", "MatchGame/view", {}, 10);
        //         }
        //     } else {
        //         UiManager.loaderViewDeepPath(this.node, "MatchGameView", "MatchGame/view", {}, 10);
        //     }
        // } else {
        //     UiManager.loaderViewDeepPath(this.node, "MatchGameView", "MatchGame/view", null, 10).then(() => {
        //         this.node.getChildByName("MatchGameView").getComponent(MatchGameViewCtrl).initGameData(null);
        //     });
        // }
    }

    start() { }

    dealReviewing() {
        // const SystemDataSys = require("./SystemDataSys").default;
        // const frameworkManager = require("./frameworkManager").default;
        // const SdkHelper = require("./SdkHelper").default;

        // if (cc.sys.os === cc.sys.OS_ANDROID && SystemDataSys.auth_type) {
        //     frameworkManager.log("防沉迷:" + SystemDataSys.auth_type);
        //     SdkHelper.ysdkLogin();
        // }

        // if (SdkHelper.getIsCheckUser() && this.checkNode) {
        //     this.checkNode.active = true;
        // }
    }
}